import request from '@/utils/request'
import type { SysRole, SysRoleDto, RolePageResult } from '@/types/role'
import type { PageQuery } from '@/types/user'

// 获取角色列表
export function getRoleList(params: { 
  data: Partial<SysRoleDto>, 
  params: PageQuery 
}) {
  return request<any, { code: number, msg: string, data: SysRole[] | RolePageResult }>({
    url: '/system/role/list',
    method: 'post',
    data: { ...params.data, ...params.params }
  })
}

// 新增角色
export function addRole(data: Partial<SysRoleDto>) {
  return request<any, { code: number, msg: string }>({
    url: '/system/role',
    method: 'post',
    data
  })
}

// 修改角色
export function updateRole(data: Partial<SysRoleDto>) {
  return request<any, { code: number, msg: string }>({
    url: '/system/role',
    method: 'put',
    data
  })
}

// 删除角色
export function deleteRole(id: string) {
  return request<any, { code: number, msg: string }>({
    url: `/system/role/${id}`,
    method: 'delete'
  })
}

// 批量删除角色
export function batchDeleteRoles(ids: string[]) {
  return request<any, { code: number, msg: string }>({
    url: '/system/role/batch',
    method: 'delete',
    data: ids
  })
} 